﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using FC.Model;


namespace FC.ViewModel.TaskScoreVMs
{
    public partial class TaskScoreListVM : BasePagedListVM<TaskScore_View, TaskScoreSearcher>
    {

        protected override IEnumerable<IGridColumn<TaskScore_View>> InitGridHeader()
        {
            return new List<GridColumn<TaskScore_View>>{
                this.MakeGridHeader(x => x.Name_view),
                this.MakeGridHeader(x => x.Score),
                this.MakeGridHeader(x => x.Name_view2),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<TaskScore_View> GetSearchQuery()
        {
            var query = DC.Set<TaskScore>()
                .Select(x => new TaskScore_View
                {
				    ID = x.ID,
                    Name_view = x.TaskItem.Name,
                    Score = x.Score,
                    Name_view2 = x.User.Name,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class TaskScore_View : TaskScore{
        [Display(Name = "标题")]
        public String Name_view { get; set; }
        [Display(Name = "_Admin.Name")]
        public String Name_view2 { get; set; }

    }
}
